package com.ssi.mrms.dao.mapping;

import com.ssi.mrms.model.RMcsdtlModel;
import com.ssi.mrms.model.RMrmlstModel;
import com.ssi.mrms.model.TowerModel;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.ResultSetExtractor;
import org.springframework.jdbc.core.RowMapper;

public class CarStickerDetailMapping implements RowMapper<RMcsdtlModel> {

    public RMcsdtlModel mapRow(ResultSet rs, int line) throws SQLException {
        ResultSetExtractor<RMcsdtlModel> extractor = new ResultSetExtractor<RMcsdtlModel>() {
            public RMcsdtlModel extractData(ResultSet rs) throws SQLException, DataAccessException {
                RMcsdtlModel model = new RMcsdtlModel();
                model.setCsdtlid(rs.getInt("CSDTLID"));
                model.setRlrmid(rs.getInt("RLRMID"));
                model.setCsdcarplt(rs.getString("CSDCARPLT"));
                model.setCsdrcvby(rs.getString("CSDRCVBY"));
                model.setCsdrcvdat(rs.getDate("CSDRCVDAT"));
                model.setCsdtyp(rs.getString("CSDTYP"));
                model.setCsdstat(rs.getString("CSDSTAT"));
                model.setCsdremark(rs.getString("CSDREMARK"));
                model.setCsdcreby(rs.getString("CSDCREBY"));
                model.setCsdcredat(rs.getDate("CSDCREDAT"));
                model.setCsdupdby(rs.getString("CSDUPDDAT"));
                model.setCsdupddat(rs.getDate("CSDUPDBY"));

                /* ---- Tower Data From Join Table------*/
                TowerModel tower = new TowerModel();
                tower.setTower(rs.getString("RLSTTOWER"));
                tower.setFloor(rs.getString("RLSTFLOOR"));
                tower.setUnitNo(rs.getString("RLSTUNITNO"));
                tower.setAddress(rs.getString("RLSTADDR"));
                model.setTower(tower);

                return model;
            }
        };
        return extractor.extractData(rs);
    }
}
